// File: entity/NovelInfo.h
#pragma once
#include <QObject>

class NovelInfo : public QObject {

    //引入信号和槽宏
    Q_OBJECT

    //声明qml可用方法
    Q_PROPERTY(QString id READ getId WRITE setId NOTIFY idChanged)
    Q_PROPERTY(QString title READ getTitle WRITE setTitle NOTIFY titleChanged)
    Q_PROPERTY(QString author READ getAuthor WRITE setAuthor NOTIFY authorChanged)
    Q_PROPERTY(QString coverPath READ getCoverPath WRITE setCoverPath NOTIFY coverPathChanged)
    Q_PROPERTY(QString description READ getDescription WRITE setDescription NOTIFY descriptionChanged)
    Q_PROPERTY(QString category READ getCategory WRITE setCategory NOTIFY categoryChanged)
    Q_PROPERTY(QString tags READ getTags WRITE setTags NOTIFY tagsChanged)
    Q_PROPERTY(QString language READ getLanguage WRITE setLanguage NOTIFY languageChanged)
    Q_PROPERTY(int status READ getStatus WRITE setStatus NOTIFY statusChanged)
    Q_PROPERTY(int chaptersCount READ getChaptersCount WRITE setChaptersCount NOTIFY chaptersCountChanged)
    Q_PROPERTY(int wordCount READ getWordCount WRITE setWordCount NOTIFY wordCountChanged)
    Q_PROPERTY(QString publishTime READ getPublishTime WRITE setPublishTime NOTIFY publishTimeChanged)
    Q_PROPERTY(QString createTime READ getCreateTime WRITE setCreateTime NOTIFY createTimeChanged)
    Q_PROPERTY(QString updateTime READ getUpdateTime WRITE setUpdateTime NOTIFY updateTimeChanged)
    Q_PROPERTY(QString lastReadChapter READ getLastReadChapter WRITE setLastReadChapter NOTIFY lastReadChapterChanged)
    Q_PROPERTY(int fileSize READ getFileSize WRITE setFileSize NOTIFY fileSizeChanged)
    Q_PROPERTY(int sourceType READ getSourceType WRITE setSourceType NOTIFY sourceTypeChanged)
    Q_PROPERTY(QString sourceUrl READ getSourceUrl WRITE setSourceUrl NOTIFY sourceUrlChanged)
    Q_PROPERTY(int loadStatus READ getLoadStatus WRITE setLoadStatus NOTIFY loadStatusChanged)
    Q_PROPERTY(double parseProgress READ getParseProgress WRITE setParseProgress NOTIFY parseProgressChanged)

    //定义构造函数和getter与setter
    public:
        explicit NovelInfo(QObject *parent = nullptr);

        // Getters
        QString getId() const;
        QString getTitle() const;
        QString getAuthor() const;
        QString getCoverPath() const;
        QString getDescription() const;
        QString getCategory() const;
        QString getTags() const;
        QString getLanguage() const;
        int getStatus() const;
        int getChaptersCount() const;
        int getWordCount() const;
        QString getPublishTime() const;
        QString getCreateTime() const;
        QString getUpdateTime() const;
        QString getLastReadChapter() const;
        int getFileSize() const;
        int getSourceType() const;
        QString getSourceUrl() const;
        int getLoadStatus() const;
        double getParseProgress() const;
        QString toString() const;

        // Setters
        void setId(const QString &id);
        void setTitle(const QString &title);
        void setAuthor(const QString &author);
        void setCoverPath(const QString &coverPath);
        void setDescription(const QString &description);
        void setCategory(const QString &category);
        void setTags(const QString &tags);
        void setLanguage(const QString &language);
        void setStatus(int status);
        void setChaptersCount(int chaptersCount);
        void setWordCount(int wordCount);
        void setPublishTime(const QString &publishTime);
        void setCreateTime(const QString &createTime);
        void setUpdateTime(const QString &updateTime);
        void setLastReadChapter(const QString &lastReadChapter);
        void setFileSize(int fileSize);
        void setSourceType(int sourceType);
        void setSourceUrl(const QString &sourceUrl);
        void setLoadStatus(int loadStatus);
        void setParseProgress(double parseProgress);

        // 声明所有 NOTIFY 信号（属性名+Changed）
        signals:
            void idChanged();
            void titleChanged();
            void authorChanged();
            void coverPathChanged();
            void descriptionChanged();
            void categoryChanged();
            void tagsChanged();
            void languageChanged();
            void statusChanged();
            void chaptersCountChanged();
            void wordCountChanged();
            void publishTimeChanged();
            void createTimeChanged();
            void updateTimeChanged();
            void lastReadChapterChanged();
            void fileSizeChanged();
            void sourceTypeChanged();
            void sourceUrlChanged();
            void loadStatusChanged();
            void parseProgressChanged();

    //定义属性
    private:
        //小说id，文件MD5
        QString id;

        //小说名字
        QString title;

        //作者：默认
        QString author;

        //封面
        QString coverPath;

        //小说描述
        QString description;

        //类别
        QString category;

        //标签
        QString tags;

        //语言:zh-CN zh-TW en
        QString language;

        //状态：0未读，1阅读中，2阅读完
        int status;

        //章节数
        int chaptersCount;

        //字数
        int wordCount;

        //发布时间
        QString publishTime;

        //创建时间
        QString createTime;

        //更新时间
        QString updateTime;

        //最后阅读掌关节
        QString lastReadChapter;

        //文件大小
        long fileSize;

        //来源：0本地导入 , 1网络来源
        int sourceType;

        //来源URL
        QString sourceUrl;

        //加载状态
        int loadStatus;

        //章节解析进度
        double parseProgress;
};
